"""
Use map and lambda expression together to
make the codes clean and beautiful.
"""


def square(x): return x * x


def multiply(x, y): return list(map(lambda s, t: s * t, x, y))


def main():
    # Ordinary style.
    squares = list(map(square, range(10)))
    print(squares)

    # A more compact way.
    squares = list(map(lambda x: x * x, range(10)))
    print(squares)

    # Another alternative way.
    xes = [x for x in range(10)]
    print(multiply(xes, xes))

    # Filter numbers that are greater than 10 in the list 'squares'.
    result = [x for x in squares if x >= 10]
    print(result)

    # Filter odd numbers.
    odds = list(filter(lambda x: x % 2 == 1, range(10)))
    print(odds)

    # List induction alternative.
    odds = [x for x in range(10) if x % 2 == 1]
    print(odds)


if __name__ == '__main__':
    main()
